package com.controller.setting;



import com.comm.R;
import com.entity.AdministrativeOffice;
import com.service.setting.SysOfficeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


//查询所有科室信息
@RequestMapping("/setting/officeManage")
@RestController
@Api(value = "科室管理数据test",tags = "科室管理数据信息接口API")
public class SysOfficeController {

    @Autowired
    private SysOfficeService sysOfficeService;

    //科室管理按钮
    @RequestMapping(value = "/findOfficeList",method = RequestMethod.GET)
    @ApiOperation(value = "显示所有科室信息接口",notes = "查询所有科室信息",httpMethod = "get", response = R.class)
    public R findOfficeList(){
        R r = sysOfficeService.findOfficeList();
        return r;
    }

    //查询按钮
    @RequestMapping(value = "/findOfficeByName",method = RequestMethod.GET)
    @ApiOperation(value = "条件查询科室信息接口",notes = "根据科室名称查询科室信息",httpMethod = "get", response = R.class)
    @ApiImplicitParam(name = "office_name",value = "科室名称",required = true,dataType = "String",paramType = "query")
    public R findOfficeByName(@RequestParam(name = "office_name") String office_name){
        R r = sysOfficeService.findOfficeByName(office_name);
        return r;
    }

    //新增按钮(有问题)
    @RequestMapping(value = "/addOfficeByName",method = RequestMethod.POST)
    @ApiOperation(value = "添加科室接口",notes = "新增一个科室",httpMethod = "post", response = R.class)
    @ApiImplicitParam(name = "office_name",value = "科室名称",required = true,dataType = "String",paramType = "query")
    //@RequestParam(name = "office_name")
    public R addOfficeByName(AdministrativeOffice office){

        R r = sysOfficeService.addOfficeByName(office);
        return r;
    }


    //编辑按钮
    @RequestMapping(value = "/updateOfficeById",method = RequestMethod.POST)
    @ApiOperation(value = "编辑科室接口",notes = "根据科室id修改科室的信息",httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "科室Id",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "office_name",value = "科室名称",paramType = "query",dataType = "String",required = true)
    })
    //@RequestParam(name = "id")Integer id,
    //@RequestParam(name = "office_name")String office_name
    public R updateOfficeById(AdministrativeOffice office){

        R r = sysOfficeService.updateOfficeById(office);
        return r;
    }

    //删除按钮
    @RequestMapping(value = "/delOfficeById",method = RequestMethod.POST)
    @ApiOperation(value = "删除科室接口",notes = "根据科室Id删除科室信息",httpMethod = "post", response = R.class)
    @ApiImplicitParam(name = "id",value = "科室Id",required = true,dataType = "int",paramType = "query")
    //@RequestParam(name = "id")
    public R delOfficeById(AdministrativeOffice office){

        R r = sysOfficeService.delOfficeById(office);
        return r;

    }

}
